package asteroids.expressions;

public abstract class ComposedExpression extends Expression {

	protected ComposedExpression(int line, int column) {
		super(line, column);
	}

	@Override
	public boolean hasAsSubExpression(Expression expression) {
		if (expression == this)
			return true;
		for (int pos = 1; pos <= getNbExpressions(); pos++)
			if (getExpressionAt(pos).hasAsSubExpression(expression))
				return true;
		return false;
	}

	public abstract int getNbExpressions();
	
	public abstract Expression getExpressionAt(int index) throws IndexOutOfBoundsException;

}
